package org.example.utils;

import lombok.Synchronized;

import java.util.concurrent.locks.ReentrantLock;

public class Test {

    public static void main(String[] args) {

        new A().start();
        new A().start();

    }
}

class A extends Thread{
    public Integer tiket = 100;
    public String name ;
    private final ReentrantLock locks = new ReentrantLock();
    public void test1(){
        //locks.lock();
        synchronized (this){
            while (tiket>0){
                tiket--;
                System.out.println(Thread.currentThread().getName() +"剩余----"+ tiket +"------张票！");
            }
        }

    }
    @Override
    public void run() {
        test1();

    }

    public static void main(String[] args) {
        A a = new A();

        a.test1();
    }
}
